Mega Code Archive

Categories
1) Android
2) ASP.Net
3) ASP.Net Tutorial
4) C
5) C Tutorial
6) C#
7) C# Book
8) C# by API
9) C# Tutorial
10) C++
11) C++ Tutorial
12) Delphi
13) Flash ActionScript
14) Flex
15) Java
16) Java Book
17) Java by API
18) Java Tutorial
19) JavaScript DHTML
20) JavaScript Reference
21) JavaScript Tutorial
22) MSOfficeExcel 2007 Tutorial
23) MSOfficePowerPoint 2007 Tutorial
24) MSOfficeWord 2007 Tutorial
25) MSSQL
26) MSSQL Tutorial
27) MySQL
28) MySQL Tutorial
29) Oracle PLSQL
30) Oracle PLSQL Tutorial
31) Perl
32) Php
33) PostgreSQL
34) Python
35) Python Tutorial
36) Ruby
37) Silverlight
38) VB.Net
39) VB.Net by API
40) VB.Net Tutorial
41) Visual C++ .NET
42) VisualBasic Script
43) XML
44) XML Tutorial
 
Ruby
1) Active Record
2) Array
3) CGI
4) Class
5) Collections
6) Database
7) Date
8) Design Patterns
9) Development
10) File Directory
11) GUI
12) Hash
13) Language Basics
14) Method
15) Network
16) Number
17) Rails
18) Range
19) Reflection
20) Statement
21) String
22) Threads
23) Time
24) Tk
25) Unit Test
26) Windows Platform
27) XML
String
1) =~ is a matching operator
2) A case-insensitive comparison is possible with casecmp, which has the same possible results as = (-1, 0, 1)
3) A pair of square brackets ([]) matches any character in the brackets
4) A pretty good heuristic for matching English words
5) A string is a sequence of letters, numbers, and other characters
6) A string literal containing a multibyte multiplication character
7) Accept dashes and apostrophes as parts of words
8) Accessing Strings
9) Add a word (plus a space)
10) Add method to system type
11) Add to both sides
12) Add two method to string class to capitalize first letter
13) Adding a call to capitalize onto the statement
14) Adding another argument, a Fixnum, returns that portion of the matched data, starting at 0 in this instance
15) Adds last character of provided string to front of self
16) Adds provided string to front of self
17) Alternate single and double quotes
18) An alternative to is the concat method (which does not allow you to chain)
19) Anchors anchor a pattern to the beginning (^) or end ($) of a line
20) Another way to build up a long string literal is by using a here document
21) Anything thats not whitespace is a word
22) Append a string with the method
23) Append one string to another with the + method
24) Append the output to an array
25) Assign strings to variables
26) Basic Special Characters and Symbols Within Regular Expressions
27) Braces ({}) specifies the exact number of digits, such as d{3} or d{4}
28) Call capitalize function from string class
29) Call concat method through string variable
30) Call downcase function from string class
31) Call each on a string with escape sequence
32) Call hash function from string class
33) Call ljust and rjust methods with an argument that is less than or equal to the length of the string
34) Call next function from string class
35) Call next function on returning result from reverse
36) Call reverse function from returning value from update function
37) Call reverse function from string class
38) Call shop function from string class
39) Call sum function from string class
40) Call swapcase function from string class
41) Call the to_s method on many built-in classes to return the contents of the object as a string
42) Call upcase function from string class on a sentence
43) Call upcase function from string on a word
44) Cant modify frozen string
45) Capitalize the result with the capitalize method, if you want
46) Case insensitive comparison (ASCII text only)
47) Casecmp method
48) Center a string
49) Center a string by filling
50) Center, left justify and right justify string
51) Chain calls of next together
52) Change a string with offset
53) Change a string with range
54) Change string to upper case in place
55) Change the output on the fly with the %s format flag and %
56) Changing the Case of a String
57) Character literal
58) Check the length of a string which has the control character inside
59) Check the string encoding
60) Checking for prefixes and suffixes
61) Checksums
62) Chomp and chomp!
63) Chomp! returns nil without altering the string because there is no record separator at the end of the string
64) Chop removes the last character (a quote) with abandon
65) Chop removes trailing character or line terminator (n, r, or rn)
66) Compare strings with the = method
67) Comparing Strings
68) Comparing With Regular Expressions
69) Concatenate (join) strings together, using a +
70) Concatenate a string to the result
71) Concatenate string by string index
72) Construct a string from hex value
73) Convert a string to a hash
74) Convert a string to an integer, use to_i
75) Convert an object to a string with to_s
76) Convert each decimal to its character equivalent with Integers chr method
77) Convert string to binary number
78) Count words for a string with quotation marks
79) Create a string is with Kernels String method
80) Creating Strings
81) Crypt a string
82) D represents a digit; it is the same as using [0-9]
83) Debugging
84) Does a string include another string
85) Double quotes interpret escaped characters and single quotes preserve them
86) Each_byte block logics
87) Each_byte takes a string apart byte by byte, returning the decimal value for the character at each index location
88) Each_line and each_byte
89) Enclose strings in double quotes
90) Enclose strings in single quotes
91) Encode command in string
92) Encoding and bytesize
93) Encoding constant
94) Enter a range to grab a range of characters
95) Enter a range to indicate a range of characters you want to change Include the last character with two dots ( )
96) Enter a string as the argument to []=, and it will return the new, corrected string, if found; nil otherwise
97) Enumerate each character as a 1-character string
98) Eql and == are slightly different
99) Escape a single quote
100) Escape backslash
101) Escape Characters list
102) Escape quotation marks with a backslash
103) Escape sequence and hex number
104) Extract numbers from a string
105) Find out the phone number
106) FOO bar gsub(fooi, The bar) gsub(barm, result)
107) Forece_encoding to change the encoding
108) Freeze a string
109) From a String to an Array
110) General Delimited Strings
111) Generating a Succession of Strings
112) Get acronym
113) Get byte from a unicode string
114) Get each char in a unicode
115) Get rid of that extra l in alll
116) Get sentences from a paragraph
117) Get substring from a string object
118) Get the longest word
119) Get the position of the first multibyte char
120) Get utf-8 encoding
121) Getting the Parts of a String You Want
122) Greek lowercase pi
123) Grouping uses parentheses to group a subexpression, like this one that contains an alternation
124) Gsub (or gsub!) replaces a substring (first argument) with a replacement string (second argument)
125) Gsub alll with all
126) Gsub does multiple substitutions at once
127) Gsub lll with ll
128) Gsub method that performs a global substitution (like a search and replace) upon the string
129) Gsub([^d]+, ) split()
130) Here Documents by number marker
131) HERE documents give you a shortcut for printing multiple lines to the console window
132) Here is number #123 gsub([a-z]i, #) gsub(#, P)
133) If a string contains any vowels
134) If you add the chr method from the Integer class, youll get the actual character
135) If you surround a section with (), the data matched is made available separately from the rest
136) In Ruby 1 9, bytes, lines, and chars are aliases
137) Index and last index a pattern
138) Index string by regular expression
139) Inserting a String in a String
140) Inserting value of a variable in a string
141) Intern a string
142) Interpret a byte as an iso-8859-15 codepoint, and transcode to UTF-8
143) Is a repetition operator
144) Is a string empty
145) Is the object frozen
146) Iterate over all the characters using a block
147) Just like w+, but doesnt consider underscore part of a word
148) Justify at both sides
149) Leading zeros cannot be dropped
150) Length and size methods both return an integer indicating how many characters a string holds
151) Line[line index(k)]
152) Loop through a string with while
153) Loop through each byte from a string
154) Make a string immutable with Objects freeze method
155) Make the print method skip to the next line without a HERE document, use the newline character, n
156) Managing Whitespace and new line character
157) Map chars in a string
158) Match alternate forms of a pattern using the pipe character ()
159) Match doesnt require a regular expression as an argument, it converts any string supplied into a regular expression
160) Match the first line just by using a word in the pattern
161) Mix single and double quotes, as long as Ruby can keep them straight
162) Negate all or part of an argument with the caret (^), similar to its use in regular expressions
163) Negative index in slice
164) Next method from Integer
165) Next value of a string
166) Next works for numbers represented as strings
167) Non letter string successor
168) Normalize Ruby source code by replacing tabs with spaces
169) Number next
170) One space longer than the word
171) Override the method from String Class
172) Paragraphs counter by split method
173) Pattern matching with regular expressions
174) Perform greater than and less than comparisons
175) Play both ends to the middle
176) Pops and returns last word off self; changes self
177) Pops last character off self and returns it, changing self
178) Print one word three times, then add or append more text with +
179) Processing a String One Word at a Time by adding a method to string class
180) Produce successive string
181) Push several strings into one
182) Pushes first character of provided string onto end of self
183) Pushes provided string onto end of self
184) Put a string with control character
185) Range indexes are negative
186) Regular expression based comparison
187) Regular Expression Character and Sub-Expression Modifiers
188) Regular expression matches a comma and a space (, )
189) Regular Expressions
190) Remove the stop words
191) Removes first character from self and returns it, changing self
192) Removing duplicates
193) Replace a substring
194) Replace first vowel with an asterisk
195) Replace string with float
196) Replacing Multiple Patterns in a Single Pass
197) Representing Unprintable Characters
198) Rescue a Attempting-to-modify exception
199) Retrieve part of a string with the [] method, using a range
200) Returning the length of each word
201) Reverse a palindrome
202) Reverse a string in or not in place
203) Rotate left
204) Rotate right
205) Scan (ww)
206) Scan a here document
207) Scan as split
208) Scan for w+
209) Scan is the iterator method you require
210) Scan through all the vowels in a string
211) Scan( )
212) Scan( u) string with hex value
213) Scan() string with hex value
214) Sequentially iterate characters as character strings
215) Shifts first word off of self and returns; changes self
216) Similar to $, the shortcut z matches the end of a string, not a line
217) Slice a string
218) Specify a Fixnum (integer) as an index, it returns the decimal character code for the character found at the index location
219) Specify ranges of characters inside the square brackets
220) Specify Unicode UTF-8, or start Ruby with -Ku option
221) Split a string into multiple pieces
222) Split a string, reverse the sequence and append them again
223) Split method can split on newlines, or multiple characters at once, to get a cleaner result
224) Split one by one
225) Split with by one or more space
226) Splitting Sentences into Words
227) Splitting Strings into Arrays with scan
228) Splitting Text into Sentences
229) Splitting up all the individual values and converting them into elements
230) Starting at the end of the string using negative numbers, get the second to last character through the eighth to last
231) String contains lowercase characters
232) String contains mixed case
233) String contains uppercase characters
234) String each_with_index
235) String from right inplace
236) String hash value
237) String next adds a character when it reaches a boundary, or adds a digit or decimal place when appropriate
238) String next is based on the character set in use
239) String operation on escape char
240) String range with string length
241) String reference
242) String slice and index
243) String starts with a capital letter
244) String to number
245) String to Symbol
246) String translation
247) Strip both sides
248) Strip from both side in place
249) Strip from left in place
250) Strip removes other kinds of whitespace, too
251) Strip the tab and new line characters
252) Substituting Variables Into an Existing String
253) Substitutions
254) Switch an English alphabet list that starts with lowercase first to a string that starts with uppercase first
255) Tab key in %q{}
256) Tab key in double quotation
257) Tab key in single quotation mark
258) Taking the first letter from a string
259) Test a string to see if it is empty before you process it
260) Test a string to see if it is empty with empty
261) Testing for presence of substring
262) Testing Sentence Separation
263) Text Manipulation
264) The !~ operator returns true if it does not match the string, false otherwise
265) The added whitespace is calculated based on the length of the string plus the value of the argument
266) The chomp and chop Methods
267) The index method returns the index location of a matching substring
268) The iso-8859-1 encoding doesnt have a Euro sign, so this raises an exception
269) The new method can take a string argument
270) The plus sign (+) operator indicates one or more of the previous pattern
271) The replace method replaces a string wholesale
272) The right side
273) The String class has the =~ method and the !~ operator
274) The string contains 6 bytes which encode 5 characters
275) The upto method from String
276) The value of the string, not its name, becomes the symbol
277) Three-line string literal
278) Throw the method in
279) To change the last two letters
280) To convert a string into a float, use the to_f method
281) To convert a string into a symbol (Symbol class), use either the to_sym or intern methods
282) To replace the first two characters of a string with Hello
283) To reverse the characters means to alter the characters so they read in the opposite direction
284) Tr method from string
285) Transform Windows-style newlines to Unix-style newlines
286) Translate and strip
287) Translation from one set of characters to another
288) Unicode string
289) Upcase does not change the original string
290) Upcase or upcase!
291) Use % for format printing
292) Use %q to represent single quote
293) Use %Q! to create a string
294) Use a method called match, provided by the String class
295) Use an offset and length (two Fixnums) to tell [] the index location where you want to start, and then how many characters you want
296) Use another character besides the default space character if youd like
297) Use case to deal with special key
298) Use center to create a comment
299) Use each_char with multibyte chars
300) Use EOF as the marker for a here document
301) Use ERB to replace string
302) Use gsub to eradicate the spaces from text string
303) Use lstrip, rstrip, and strip (lstrip!, rstrip!, and strip!)
304) Use more than one character the sequence will be repeated
305) Use pairs of delimiters, such as { and } or and when quoting
306) Use regular expressions
307) Use string as array
308) Use tab key in %Q{}
309) Use Tab key in {}
310) Use two ls instead of one for delete method
311) Use whitespace as the place holder
312) Uses d to match any digit, and the + that follows d makes d match as many digits in a row as possible
313) Using quotation marks is only viable for a single line, but if you want to span multiple lines
314) Using the + symbol concatenates the two strings
315) Using the length Method of the String Class
316) What if you want to print out a line of text three times
317) When there is more than one argument, take the intersection
318) With delete or delete!, you can delete characters from a string
319) Word-wrapping Lines of Text
320) Wrap a string with new line sing
321) Write an extension to the String class to provide it
322) Writing an Inherited Class
323) XML uses paired angle brackets
324) You can multiply strings
325) You can omit the Q altogether
326) You cannot mix double-quoted text inside a double-quoted string, or single-quoted text inside a single-quoted string
327) You cannot multiply two strings
328) You dont even have to use single or double quotes to create a string